package com.koron.ticket.work.workinfo.controller;

import com.koron.bean.base.Response;
import com.koron.common.core.config.ThreadLocalContext;
import com.koron.ticket.work.workinfo.bean.WorkInfo;
import com.koron.ticket.work.workinfo.mapper.WorkInfoMapper;
import com.koron.ticket.work.workinfo.service.WorkInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.koron.ebs.mybatis.ADOConnection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("work/workinfo")
@Api(tags = "两票管理-工作详情")
public class WorkInfoController {

    private String getCurrDs() {
        return ThreadLocalContext.get().getCurrDs();
    }

    @Autowired
    private WorkInfoService workInfoService;

    @PostMapping("update")
    @ApiOperation("工作详情更新")
    public Response update(@RequestBody WorkInfo workInfo) {
        return ADOConnection.runTask(getCurrDs(), factory -> {
            WorkInfoMapper workInfoMapper = factory.getMapper(WorkInfoMapper.class);
            workInfoMapper.update(workInfo);
            return Response.ok();
        }, Response.class);
    }
}
